package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.OldFoodService;
import com.ruoyi.system.service.IOldFoodServiceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 社区养老订餐Controller
 * 
 * @author ruoyi
 * @date 2021-07-05
 */
@RestController
@RequestMapping("/system/foot")
public class OldFoodServiceController extends BaseController
{
    @Autowired
    private IOldFoodServiceService oldFoodServiceService;

    /**
     * 查询社区养老订餐列表
     */
//    @PreAuthorize("@ss.hasPermi('system:service:list')")
    @GetMapping("/list")
    public TableDataInfo list(OldFoodService oldFoodService)
    {
        startPage();
        List<OldFoodService> list = oldFoodServiceService.selectOldFoodServiceList(oldFoodService);
        return getDataTable(list);
    }

    /**
     * 导出社区养老订餐列表
     */
//    @PreAuthorize("@ss.hasPermi('system:service:export')")
    @Log(title = "社区养老订餐", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OldFoodService oldFoodService)
    {
        List<OldFoodService> list = oldFoodServiceService.selectOldFoodServiceList(oldFoodService);
        ExcelUtil<OldFoodService> util = new ExcelUtil<OldFoodService>(OldFoodService.class);
        return util.exportExcel(list, "service");
    }

    /**
     * 获取社区养老订餐详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:service:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(oldFoodServiceService.selectOldFoodServiceById(id));
    }

    /**
     * 新增社区养老订餐
     */
//    @PreAuthorize("@ss.hasPermi('system:service:add')")
    @Log(title = "社区养老订餐", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OldFoodService oldFoodService)
    {
        return toAjax(oldFoodServiceService.insertOldFoodService(oldFoodService));
    }

    /**
     * 修改社区养老订餐
     */
//    @PreAuthorize("@ss.hasPermi('system:service:edit')")
    @Log(title = "社区养老订餐", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OldFoodService oldFoodService)
    {
        return toAjax(oldFoodServiceService.updateOldFoodService(oldFoodService));
    }

    /**
     * 删除社区养老订餐
     */
//    @PreAuthorize("@ss.hasPermi('system:service:remove')")
    @Log(title = "社区养老订餐", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(oldFoodServiceService.deleteOldFoodServiceByIds(ids));
    }
}
